package stack;

import stack.MyStack;

import java.util.Arrays;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: qian
 * Date: 2022-06-30
 * Time: 10:09
 */
public class Test {
    public static int removeDuplicates(int[] nums) {
        int count=nums.length;
        int cur=nums[0];
        int i=1;
        while(i<count){
            if(nums[i]==nums[i-1]){
                int k=i;
                while(k<count-1){
                    nums[k]=nums[k+1];
                    k++;
                }
                count--;
            }else{
                i++;
            }
        }
        return count;
    }

    public static void main(String[] args) {
        int[] arr={0,0,1,1,1,2,2,3,3,4};
        System.out.println(removeDuplicates(arr));
    }
    public static void transform(int[] arr){
        for (int i = 0; i < arr.length; i++) {
            arr[i]=arr[i]*2;
        }
    }
    public static void main4(String[] args) {
        int[] arr=new int[]{1,2,4};
        transform(arr);
        System.out.println(Arrays.toString(arr));
    }
    public static void main3(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int n=scanner.nextInt();
        int i=0;
        for ( i = 2; i < Math.sqrt(n) ; i++) {    //从2循环到根号n
            if(n%i==0){
                System.out.println(n+"不是素数");
                break;
            }
        }
        if(i==Math.sqrt(n)){
            System.out.println(n+"是素数");
        }
    }
    public static boolean Prime(int n) {
        int i = 0;
        for (i = 2; i <= Math.sqrt(n); i++) {    //从2循环到根号n
            if (n % i == 0) {
                return false;
            }
        }
        return  true;
    }

    public static void main2(String[] args) {
        for(int i = 1 ; i <= 100 ; i++){
            if(Prime(i)){
                System.out.println(i);
            }
        }
    }
    public static void main1(String[] args) {
        MyStack<Integer> myStack=new MyStack<>();
        myStack.push(12);
        myStack.push(23);
        System.out.println(myStack.size());//2
        System.out.println(myStack.isFull());//F
        System.out.println(myStack.empty());//F
        System.out.println(myStack.peek());//23
        System.out.println(myStack.pop());//23
        System.out.println(myStack.peek());//12
        System.out.println(myStack.pop());//12
        System.out.println(myStack.empty());//T

    }
}
